package com.example.uidemo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

public class MainActivity extends AppCompatActivity {

    private LinearLayout mLinearLayout;
    private View mView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mLinearLayout = findViewById(R.id.linear_layout);
        mLinearLayout.setOnClickListener(v -> {
            mView = View.inflate(MainActivity.this, R.layout.layout_item, null);
            if (v.getId() == R.id.linear_layout){
                mLinearLayout.addView(mView);
            }
        });
    }
}